package com.platform.study.thread;

/**
 * 用实现Runnable接口方式实现线程:线程休眠
 * User: wangyanginfo
 * Date: 12-11-26
 * Time: 下午2:44
 */
public class RunnableSimple_3 implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 3; i++) {
            try {
                Thread.sleep(2000); //线程休眠
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());
        }
    }

    public static void main(String[] args) {
        RunnableSimple_3 simpleA = new RunnableSimple_3();
        Thread thread = new Thread(simpleA, "线程1");
        System.out.println("线程启动之前---》" + thread.isAlive());
        thread.start();
        System.out.println("线程启动之后---》" + thread.isAlive());
    }
}
